﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;

namespace thousandClear.Util.Logging
{
    public enum LoggerCategoryEnum
    {
        Trace,
        Exception,
    }

    public class Log4NetLogger : ILogger
    {
        public string _name;

        

        public Log4NetLogger(string name)
        {
            _name = name;
        }

        private ILog GetLogger(LoggerCategoryEnum category)
        {
            ILog logger = log4net.LogManager.GetLogger(string.Format("{0}_{1}", _name, category));
            return logger;
        }

        public void Debug(string message)
        {
            GetLogger(LoggerCategoryEnum.Trace).Debug(string.Format("\r\nMessage: {0}", message));
        }

        public void Debug(string message, Exception exception)
        {
            GetLogger(LoggerCategoryEnum.Exception).Debug(string.Format("\r\nMessage: {0}\r\nException: {1}", message, exception));
        }

        public void Fatal(string message)
        {
            GetLogger(LoggerCategoryEnum.Trace).Fatal(string.Format("Message: {0}", message));
        }

        public void Fatal(string message, Exception exception)
        {
            GetLogger(LoggerCategoryEnum.Exception).Fatal(string.Format("Message: {0} - Exception: {1}", message, exception));
        }

        public void Info(string message)
        {
            GetLogger(LoggerCategoryEnum.Trace).Info(string.Format("Message: {0}", message));
        }

        public void Warning(string message)
        {
            GetLogger(LoggerCategoryEnum.Trace).Warn(string.Format("Message: {0}", message));
        }

        public void Error(string message)
        {
            GetLogger(LoggerCategoryEnum.Trace).Error(string.Format("Message: {0}", message));
        }

    }
}
